<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=640,user-scalable=no" />
		<title>你办囍事 我送囍酒</title>
		<script>
			var jsonDataObj = <?php echo $jsonDataObj;?>;
			var userUrl = {
				"name": "<?php echo $userInfo['name'];?>;",
				"url": "<?php echo $userInfo['image'];?>"
			};
		</script>
		<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/reset.css" />
		<!--<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/desk.css" />-->
		<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/createBanquet.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo C('HTTP_HOST_URL');?>/Public/game/css/animate.css" />
	</head>

	<body>
		<?php
 $jssdk = new \JSSDK("wxfd8742a962585bcd", "1390437b5921430a49b529c4a79aba62"); $signPackage = $jssdk->GetSignPackage(); ?>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId:  '<?php echo $signPackage["appId"];?>', // 必填，公众号的唯一标识
        timestamp:<?php echo $signPackage["timestamp"];?>, // 必填，生成签名的时间戳
        nonceStr: '<?php echo $signPackage["nonceStr"];?>', // 必填，生成签名的随机串
        signature: '<?php echo $signPackage["signature"];?>',// 必填，签名，见附录1
        jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage'
        ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function () {
        initShareTimeline();
        initShareAppMessage();
//      music.play();
    });


/**
 * 初始化分享到朋友圈的设置
 */
function initShareTimeline(title,link,imgUrl){
	title= title?title:"<?php echo $BanquetUserInfo['name'];?>要结婚了，快来Ta的婚宴抢个座！";
	link= link?link:"<?php echo \Org\Net\Fun::url('home/page/table',array('id'=>$BanquetInfo['id'])); ?>";
	imgUrl = imgUrl?imgUrl:"<?php echo C('HTTP_HOST_URL');?>/Public/images/share.png";
    //分享到朋友圈
    wx.onMenuShareTimeline({
        title: title, // 分享标题
        link: link, // 分享链接
        imgUrl: imgUrl, // 分享图标
        trigger: function(res) {
		// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
		//              alert('用户点击分享到朋友圈');
            
		},
		success: function(res) {
            <?php if($BanquetUserInfo['wx_id']==$userInfo['wx_id']):?>
            if(showwel){
            		try{
            			if (typeof(eval("showwel")) == "function") {
			           showwel(3);
			        }
            		}catch(e){
            			
            		}
            }
            
            <?php endif;?>
//			sharelog();
			///////////////////////////////////////////////
//			close_mask();
            
            
		},
		cancel: function(res) {
		},
		fail: function(res) {
		}
    });
}


/**
 * 初始化分享好友的设置
 */
function initShareAppMessage(title,desc,link,imgUrl){ 
	
	title= title?title:"<?php echo $BanquetUserInfo['name'];?>要结婚了，快来Ta的婚宴抢个座！";
	desc=desc?desc:"你办囍事，我送囍酒";
	link= link?link:"<?php echo \Org\Net\Fun::url('home/page/table',array('id'=>$BanquetInfo['id'])); ?>";
	imgUrl = imgUrl?imgUrl:"<?php echo C('HTTP_HOST_URL');?>/Public/images/share.png";
	//分享给朋友
    wx.onMenuShareAppMessage({
        title: title, // 分享标题
        desc: desc, // 分享描述
        link: link, // 分享链接
        imgUrl: imgUrl, // 分享图标
		trigger: function(res) {
            
			// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
			//          alert('用户点击发送给朋友');
		},
		success: function(res) {
            <?php if($BanquetUserInfo['wx_id']==$userInfo['wx_id']):?>
             
        		try{
        			if (typeof(eval("showwel")) == "function") {
		           showwel(3);
		        }
        		}catch(e){
        			
        		}
            <?php endif;?>
//			sharelog();
			///////////////////////////////////////////////////////
//			close_mask();
            
		},
		cancel: function(res) {
		},
		fail: function(res) {
		}
    });
}
    
//提交分享记录    
function sharelog(){
	MYajax({"type":"share"},"/index.php/Home/app/share.html",function(res){})
}


//秘钥
var tokenkey = "lkasdj213489ulkjadsf";
function MYajax(requestData,url,successCallback){
	var requestData = requestData;
	var url = url;
	requestData = JSON.stringify(requestData);
	var requestKey = $.md5(requestData+tokenkey);
	$.ajax({
		type:"post",
		url:url,
		data:{'data':requestData,"key":requestKey},
		async:true,
		success:function(res){
			successCallback(res);
		},
		dataType:'json',
		fail:function(e){
			
		}
	});
}
</script>
		<div class="web">
			<audio src="/Public/game/music/1.mp3" autoplay loop=""></audio>
			<div class="music xuanzhuan"></div>
			
			
			<!--页面进入时触发的遮罩-->
			<div class="welcome">
				<!--第一个首页生成宴席时的欢迎语-->
				<div class="animated bounceIn">
					囍宴摆好了,<br />快让亲朋亲友入席!
					<div class="remove"><img src="/Public/game/images/close_icon.jpg"/></div>
				</div>
				<!--第二个首页朋友进入席位时的欢迎语,默认隐藏,专属样式名字为.btns_f-->
				<div class="btns btns_f animated bounceIn">
					欢迎来到<?php echo ($BanquetInfo["wx_name"]); ?>的宴席<br />
					<button>我要入席</button><br />
					<button>查看宴席排行榜</button><br />
					<button>我要制作我的宴席</button><br />
					<div class="remove"><img src="/Public/game/images/close_icon.jpg"/></div>
				</div>
				<!--第三个首页我要入榜时的欢迎语,默认隐藏,专属样式名字为.btns_s-->
				<div class="btns btns_s animated bounceIn">
					欢迎来到<?php echo ($BanquetInfo["wx_name"]); ?>的宴席<br /><br />
					<button>我要入榜,<br />赢取999元现金</button><br /><br />
					<button>查看宴席排行榜</button><br />
					<div class="remove"><img src="/Public/game/images/close_icon.jpg"/></div>
				</div>
				<!--第四个首页我要入榜时的欢迎语,默认隐藏-->
				<div class="btns btns_t animated bounceIn">
					为Ta收集更多新婚祝福!
					<div class="remove"><img src="/Public/game/images/close_icon.jpg"/></div>
				</div>
				
				<!--平时弹出来使用输出信息的-->
				<div class="btns btns_alert animated bounceIn">
					<div>这就是信息</div>
					<div class="remove"><img src="/Public/game/images/close_icon.jpg"/></div>
				</div>
			</div>
			<!--页面正文标题部分-->
			<!--第二,三首页进入时标题内容隐藏,但为防止中间桌子的内容部分顶到顶部,请给.title设置30px的高度-->
			<div class="title">
				
				<span><?php echo ($BanquetInfo['wx_name']); ?></span><span>家的囍宴</span>
			</div>
			<!--页面正文的桌子部分-->
			<div class="content">
				<div class="desk desk_b" data-index=0>
					<div class="cencir"><p>主宾桌</p></div>
					<div class="seat seat1 " data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2 " data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3  " data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5 " data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s" data-index=1>
					<div class="cencir"><p>第1席</p></div>
					<div class="seat seat1 " data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2" data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3" data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5" data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s" data-index=2>
					<div class="cencir"><p>第2席</p></div>
					<div class="seat seat1" data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2" data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3" data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5" data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s" data-index=3>
					<div class="cencir"><p>第3席</p></div>
					<div class="seat seat1" data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2" data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3" data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5" data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s" data-index=4>
					<div class="cencir"><p>第4席</p></div>
					<div class="seat seat1" data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2" data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3" data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5" data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s" data-index=5>
					<div class="cencir"><p>第5席</p></div>
					<div class="seat seat1" data-index=0>
						<img src="/Public/game/images/seated_bg.png"/>
					</div>
					<div class="seat seat2" data-index=1>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat3" data-index=2>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat4" data-index=3>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat  seat5" data-index=4>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
					<div class="seat seat6" data-index=5>
						<img src="/Public/game/images/seated_bg.png"  />
					</div>
				</div>
			
				<div class="desk desk_s desk_jia" data-index=6>
					<div class="cencir"><p>+</p></div>
					<div class="seat seat1" data-index=0>
						<!--<img src="/Public/game/images/seated_bg.png"/>-->
					</div>
					<div class="seat seat2" data-index=1>
						<!--<img src="/Public/game/images/seated_bg.png"  />-->
					</div>
					<div class="seat  seat3" data-index=2>
						<!--<img src="/Public/game/images/seated_bg.png"  />-->
					</div>
					<div class="seat  seat4" data-index=3>
						<!--<img src="/Public/game/images/seated_bg.png"  />-->
					</div>
					<div class="seat  seat5" data-index=4>
						<!--<img src="/Public/game/images/seated_bg.png"  />-->
					</div>
					<div class="seat seat6" data-index=5>
						<!--<img src="/Public/game/images/seated_bg.png"  />-->
					</div>
				</div>
				
			</div>
			<!--页面正文尾部-->
			<div class="footer">
				<?php if($isWeb==1):?>
				<!--第一个首页的底部-->
				<div class="btn">
					生成囍宴,分享囍事
				</div>
				<?php endif;?>
				
				
				
				<!--第二/三个首页的脚步,默认为display:none-->
				<div class="btns_f">
					您是第
					<?php echo $BanquetInfo['people'];?>位宾客,目前已有
					<?php echo $BanquetInfo['people']-1;?>位宾客入席
				</div>
			</div>

			<!--桌子切换变大时动态的页脚内容-->
			<div class="mask">
				<p>您已成功入席</p>
				您的座位是第<span class="fa_pos"><?php echo $meTable['position']+1;?></span>桌 第
				<span class="sel_pos"><?php echo $mePar['position'];?></span>位
			</div>
			
			<div id="canvas"></div>
		</div>
		<!--返回首页-->
		<div class="bot">
			<button></button>
		</div>
		<input type="hidden" class="hasP" value="<?php echo ($hasP); ?>" />

	
		<!--********改动   START************-->
		<script src="/Public/game/js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="/Public/game/js/lufylegend-1.10.1.js" type="text/javascript" charset="utf-8"></script>
		<script src="/Public/game/js/plugin.js" type="text/javascript" charset="utf-8"></script>
		


		<script type="text/javascript">
			var loadData = [{
				name: "sugar",
				path: "/Public/game/images/sugar.png"
			}];
			var dw =640,dh=1136,dataList,sugarArr=[],time;
			init(1000 / 40, "canvas", dw, dh, function() {
				if(LGlobal.mobile) {
					LGlobal.stageScale = LStageScaleMode.FIXED_WIDTH;
					LGlobal.fixedMode = LStageScaleMode.FIXED_MODE_TOP;
				} else {
					LGlobal.stageScale = LStageScaleMode.SHOW_ALL;
				}
				LSystem.screen(LStage.FULL_SCREEN);
//				LMouseEventContainer.set(LMouseEvent.MOUSE_DOWN, true);
				LLoadManage.load(loadData, function(progress) {
				}, function(result){
					dataList = result;
					var stageLayer = new LSprite();
					stageLayer.addEventListener(LEvent.ENTER_FRAME, gameLoop.bind(stageLayer));
					time = setInterval(function(){
						for(var i=0;i<5;i++){
							var Sprite =new LBitmap(new LBitmapData(dataList['sugar']));
							this.addChild(Sprite);
							Sprite.x = Math.random()*1000-200;
							Sprite.y = Math.random()*-300-40;
							Sprite.rotate =  Math.random()*100;
							sugarArr.push(Sprite);
							
						}
					},500);
					addChild(stageLayer);
				});
			});
			function gameLoop(){
				for(var i=0;i<sugarArr.length;i++){
					sugarArr[i].y+=10;
					sugarArr[i].x +=Math.random()*3;
					sugarArr[i].alpha-=Math.random()*10;
					sugarArr[i].rotate +=  Math.random()*2;
				}
				
				if(sugarArr.length>=35){
					clearInterval(time);
					$("#canvas").transition({opacity:0},1000,function(){
						$(this).remove()
					})
					
				}
				
			}
		</script>
		<!--********改动   end************-->
		
		
		
		<script src="<?php echo C('HTTP_HOST_URL');?>/Public/game/js/desk.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo C('HTTP_HOST_URL');?>/Public/game/js/jquery.transit.js" type="text/javascript" charset="utf-8"></script>
		<script src="<?php echo C('HTTP_HOST_URL');?>/Public/game/js/jQuery.md5.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function showwel(n,msg) {
				$(".welcome").css({"display":"block","opacity":"1"});
				//第一个首页欢迎语出现,第二三个欢迎隐藏
				if(n == 1) {
					$(".welcome div:first").css("display", "block");
					$(".btns_f").css("display", "none");
					$(".btns_s").css("display", "none");
					$(".btns_t").css("display", "none");
					$(".btns_alert").css("display", "none");
					
				};
				//第二个首页欢迎语出现,第一三个欢迎隐藏
				if(n == 2) {
					$(".welcome div:first").css("display", "none");
					$(".btns_s").css("display", "none");
					$(".btns_f").css("display", "block");
					$(".btns_t").css("display", "none");
					$(".btns_alert").css("display", "none");
					
				};
				//第三个首页欢迎语出现,第一二个欢迎隐藏
				if(n == 3) {
					$(".welcome div:first").css("display", "none");
					$(".btns_t").css("display", "none");
					$(".btns_s").css("display", "block");
					$(".btns_f").css("display", "none");
					$(".btns_alert").css("display", "none");
					
				}
				if(n==5){
					$(".btns_alert div:first-child").html(msg);
					$(".welcome div:first").css("display", "none");
					$(".btns_t").css("display", "none");
					$(".btns_s").css("display", "none");
					$(".btns_f").css("display", "none");
					$(".btns_alert").css("display", "block");
					
				}
			}

			var number = 'lkasdj213489ulkjadsf';
			

			//朋友参与
			<?php if($BanquetInfo['wx_id'] != $userInfo['wx_id']):?>
			showwel(2);
			<?php endif;?>

			//创建宴席
			<?php if($BanquetInfo['wx_id'] == $userInfo['wx_id'] && $isWeb==1):?>
//			showwel(1);
			<?php endif;?>

			//自己回来看宴席
			<?php if($BanquetInfo['wx_id'] == $userInfo['wx_id'] && $isWeb==0):?>
			showwel(3);
			<?php endif;?>
			
				
			$(".bot button").on("touchstart", function() {
				location.href = "<?php echo \Org\Net\Fun::url('home/page/index'); ?>";
			});
			$(".btns_f button:first").on("touchstart", function() {
				$(".welcome").css("display", "none");
			});

			//查看宴会排行榜
			$(".btns_f button:nth-of-type(2)").on("touchstart", function() {
					location.href = "<?php echo \Org\Net\Fun::url('home/page/rankingList'); ?>"
				})
				//第二个弹出层的我要制造我的宴席
			$(".btns_f button:nth-of-type(3)").on("touchstart", function() {
				location.href = "<?php echo \Org\Net\Fun::url('home/page/index'); ?>";
			});

			//第三个弹出层，我要入榜
			$(".btns_s button:nth-of-type(1)").on("touchstart", function() {
					location.href = "<?php echo \Org\Net\Fun::url('home/page/information'); ?>";
				})
				//第三个弹出层，查看排行榜
			$(".btns_s button:nth-of-type(2)").on("touchstart", function() {
					location.href = "<?php echo \Org\Net\Fun::url('home/page/rankingList'); ?>";
					//location.href = "Ranking.html"
				})
				//第一个首页底部的链接弹出	
			$(".footer .btn").on("touchstart", function() {
				showwel(1);
			})


			//音乐
			var mu=$(".music");
			var music=$("audio")[0];
			mu.on("touchstart",function() {
				mu.toggleClass("xuanzhuan");
				if(music.paused == false) {
					music.pause();
				} else {
					music.play();
				}
			})


			//为每个座位添加事件
			function seatClickFun(e) {
				var _s = $(this);
				e.stopPropagation();
				if($(this).find("img").attr("src") == "/Public/game/images/seated_bg.png") {
					var hasp = $(".hasP").val();
					if(hasp != 1) {
						var sel_index = $(this).data("index");
						var fa_index = $(this).parent().data("index");
						console.log(sel_index);
						console.log(fa_index);
						//把当前用户的头像信息放到json里面,这里要保证json长度够,并且要把赋值后的json传给后台保存
						jsonDataObj[fa_index][sel_index].name = userUrl.name;
						jsonDataObj[fa_index][sel_index].url = userUrl.url;

						var postData = {
							"banquet_id": <?php echo $BanquetInfo['id'];?>,
							"table_id": fa_index,
							"position": sel_index
						};
						var qwer = JSON.stringify(postData);
						var asdf = $.md5(qwer + number);
						var url = '<?php echo \Org\Net\Fun::url("home/page/addParticipate") ?>';

						var postData = {
							'qwer': qwer,
							"session_id": asdf
						};
						$.post(url, postData, function(data) {
							if(data.state == 1) {
								var address = userUrl.url;
								_s.find("img").attr("src", address);
								$(".fa_pos").text(fa_index+1);
								$(".sel_pos").text(sel_index + 1);
								$(".hasP").val(1);
								//!!!!!!!!!!!弹出文字修改
								showwel(5,"您已成功入座<br/>为Ta收集更多新婚祝福");
								return;
							}
							showwel(5,data.message);
						}, "json");
					} else {
						showwel(5,"你已经不能再选");
					}
				}else{
					showwel(5,"该座位已被预订");
				}
			}
		</script>

	</body>
	</html>